package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo04Map {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName(this.getClass.getSimpleName.replace("$", ""))
    val sc = new SparkContext(conf)


    /**
     * map算子：转换算子
     * 传入一行数据返回一行数据
     */

    val rdd: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5, 6))

    // 将每个值*2
    rdd
      .map(i => i * 2)
      .foreach(println)


  }

}
